<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <title>任务表单</title>
    <style>
        body {
            font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f9f9f9;
            max-width: 600px;
            margin: 40px auto;
            padding: 20px;
            color: #333;
            box-shadow: 0 0 12px rgba(0,0,0,0.1);
            border-radius: 8px;
            background: white;
        }
        h2 {
            text-align: center;
            margin-bottom: 25px;
            color: #2c3e50;
        }
        form {
            display: flex;
            flex-direction: column;
        }
        label {
            margin-bottom: 6px;
            font-weight: 600;
            color: #555;
        }
        input[type="text"],
        input[type="number"],
        select,
        textarea {
            padding: 8px 12px;
            margin-bottom: 18px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 1rem;
            transition: border-color 0.3s;
        }
        input[type="text"]:focus,
        input[type="number"]:focus,
        select:focus,
        textarea:focus {
            border-color: #2980b9;
            outline: none;
        }
        textarea {
            resize: vertical;
        }
        .checkbox-container {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
        }
        .checkbox-container input[type="checkbox"] {
            margin-right: 8px;
            width: 18px;
            height: 18px;
        }
        button {
            background-color: #2980b9;
            color: white;
            font-weight: 700;
            padding: 10px 0;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1.1rem;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #1c5980;
        }
        a {
            display: block;
            margin-top: 20px;
            text-align: center;
            color: #2980b9;
            text-decoration: none;
            font-weight: 600;
            transition: color 0.3s;
        }
        a:hover {
            color: #1c5980;
            text-decoration: underline;
        }
    </style>
</head>
<body>
<h2 th:text="${task.id == null} ? '新增任务' : '编辑任务'">新增任务</h2>

<form action="/task" method="post" th:object="${task}">
    <input type="hidden" th:field="*{id}" />

    <label for="name">名称：</label>
    <input id="name" type="text" th:field="*{name}" required />

    <label for="url">URL：</label>
    <input id="url" type="text" th:field="*{url}" required />

    <label for="method">请求方法：</label>
    <select id="method" th:field="*{method}" required>
        <option value="POST">POST</option>
        <option value="GET">GET</option>
    </select>

    <label for="contentType">Content-Type：</label>
    <input id="contentType" type="text" th:field="*{contentType}" placeholder="application/json;charset=GB2312" />

    <label for="params">请求参数（JSON）：</label>
    <textarea id="params" th:field="*{params}" rows="6"></textarea>

    <label for="intervalSeconds">间隔时间（秒）：</label>
    <input id="intervalSeconds" type="number" th:field="*{intervalSeconds}" required />

    <div class="checkbox-container">
        <input id="active" type="checkbox" th:field="*{active}" />
        <label for="active" style="margin:0;">激活状态</label>
    </div>

    <button type="submit">保存</button>
</form>

<a href="/">返回</a>
</body>
</html>
